const express = require('express');
const cors = require('cors');
const app = express();
const { encode, decode } = require('./utils/token.js');
const { tokenerr } = require('./utils/err.js');
app.use(express.static('static'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cors());
const sercekey = 'TODOkey';
app.use(
  decode(sercekey).unless({
    path: ['/user/login', '/user/register'],
  })
);
app.use(tokenerr);
const router = require('./router/index.js');
app.use(router);

app.listen(8000, () => {
  console.log('server is running at http://127.0.0.1:8000');
});
